package twoDayMoreThread;

public class Threadsyn1 implements Runnable{
    private int count=0;

    @Override
    public void run() {
        while (true){
            synchronized (this){
                if (count<=100){
                    System.out.println(Thread.currentThread().getName()+":"+count++);
                    notify();

                    try {
                        wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        Threadsyn1 threadsyn1 = new Threadsyn1();

        Thread thread1 = new Thread(threadsyn1, "thread1");
        Thread thread2 = new Thread(threadsyn1, "thread2");

        thread1.start();
        thread2.start();
    }
}
